//Thursday, November 05 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

				 using namespace std;

		 template<class T> inline void checkmax(T &a,T b){if(b>a) a=b;}

		 class EggCartons
		 {
			 public:
				 int minCartons(int n)
				 {
					 for(int i=0; i<=n/6; i++)
						 for(int j=0; j<=n/8; j++)
					 {
						 if((i>0||j>0) && 8*j+6*i == n)
							 return i+j;
					 }
					 return -1;
				 }
		 };
